package model

import (
	"manager/model/entity"

	"github.com/lib/pq"
)

// FirmwaresRecordCreateRequest 创建现场数据
type FirmwaresRecordCreateRequest struct {
	FirmwareId int64 `json:"firmware_id"`

	TacticsId int64 `json:"tactics_id"`

	Version string `json:"version"`

	EbikesType pq.Int64Array `json:"ebikes_type"`

	FirmwaresName string `json:"firmwares_name"`
}

// FirmwaresRecordUpdateRequest 更新现场数据
type FirmwaresRecordUpdateRequest struct {
	Id int64 `json:"id"`

	FirmwareId *int64 `json:"firmware_id"`

	TacticsId *int64 `json:"tactics_id"`

	Version *string `json:"version"`

	EbikesType *pq.Int64Array `json:"ebikes_type"`

	FirmwaresName *string `json:"firmwares_name"`

	CreatedAt int64 `json:"created_at"`
}

// FirmwaresRecordListRequest 列表现场数据
type FirmwaresRecordListRequest struct {
	Index int `json:"index"`
	Size  int `json:"size"`

	Id int64 `json:"id"`

	FirmwareId *int64 `json:"firmware_id"`

	TacticsId *int64 `json:"tactics_id"`

	Version *string `json:"version"`

	EbikesType *pq.Int64Array `json:"ebikes_type"`

	FirmwaresName *string `json:"firmwares_name"`
}

// FirmwaresRecordListResponse 列表回包数据
type FirmwaresRecordListResponse struct {
	Total int                    `json:"total"`
	List  []*FirmwaresRecordInfo `json:"list"`
}

// FirmwaresRecordInfoRequest 列表现场数据
type FirmwaresRecordInfoRequest struct {
	Id int64 `json:"id"`

	FirmwareId *int64 `json:"firmware_id"`

	TacticsId *int64 `json:"tactics_id"`

	Version *string `json:"version"`

	EbikesType *pq.Int64Array `json:"ebikes_type"`

	FirmwaresName *string `json:"firmwares_name"`
}

// FirmwaresRecordInfo 详细数据
type FirmwaresRecordInfo struct {
	Id int64 `json:"id"`

	FirmwareId int64 `json:"firmware_id"`

	TacticsId int64 `json:"tactics_id"`

	Version string `json:"version"`

	EbikesType pq.Int64Array `json:"ebikes_type"`

	FirmwaresName string `json:"firmwares_name"`

	CreatedAt int64 `json:"created_at"`
}

// FirmwaresRecordDeleteRequest 删除现场数据
type FirmwaresRecordDeleteRequest struct {
	Id int64 `json:"id"`
}

// FirmwaresRecordsEntityToDto entity数据转换
func FirmwaresRecordsEntityToDto(firmwaresRecords []*entity.FirmwaresRecord) []*FirmwaresRecordInfo {
	out := make([]*FirmwaresRecordInfo, 0, len(firmwaresRecords))
	for _, c := range firmwaresRecords {
		out = append(out, FirmwaresRecordEntityToDto(c))
	}
	return out
}

// FirmwaresRecordEntityToDto entity数据转换
func FirmwaresRecordEntityToDto(e *entity.FirmwaresRecord) *FirmwaresRecordInfo {
	return &FirmwaresRecordInfo{

		Id: e.Id,

		FirmwareId: e.FirmwareId,

		TacticsId: e.TacticsId,

		Version: e.Version,

		EbikesType: e.EbikesType,

		FirmwaresName: e.FirmwaresName,

		CreatedAt: e.CreatedAt,
	}
}
